//
//  NNInputViewController.swift
//  CommonTool
//
//  Created by tenroadshow on 11.3.22.
//

import UIKit

class NNInputViewController: UIViewController {

    lazy var showBtn: UIButton = {
        let btn = UIButton(type: .custom)
        btn.backgroundColor = .random
        btn.addTarget(self,
                      action: #selector(showKeyboard),
                      for: .touchUpInside)
        return btn
    }()
        
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        
        view.addSubview(showBtn)
        showBtn.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(150)
            make.centerX.equalToSuperview()
            make.size.equalTo(CGSize(width: 200, height: 50))
        }
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        addKeyboardNotification()
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        removeKeyboardNotification()
    }
    
    
    @objc func showKeyboard() {
        
        
        if customInputView == nil {
            customInputView = NNInputView(contentHeight: 150)
        }
        customInputView?.show(content: "请输入123", completeHandle: { content in
            CC.log("content = \(content)")
        })
    }
}
